<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/11/13 0013
 * Time: 下午 2:57
 */

namespace app\controller;


use think\captcha\facade\Captcha;
use think\facade\Validate;

class Code
{


    function index(){

        //使用独立的验证码
        return Captcha::create('verify');
    }
    function form(){

        return view("form");
    }

    function check(){

//
//        $validate = Validate::rule([
//            'captcha'=>'require|captcha'
//        ]);
//
//        $result = $validate->check([
//            'captcha'=>input("code")
//        ]);
//
//
//        dd($result);
//        dd($validate->getError());

        if(!captcha_check(input("code"))){


            return "验证码错误";
        }

    }
}